package com.jsy.mini12306.ticketsales.controller;

import com.jsy.mini12306.common.entity.Station;
import com.jsy.mini12306.ticketsales.service.StationService;
import com.jsy.mini12306.ticketsales.vo.StationsByFirstCharVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 车站（字典表）(Station)表控制层
 *
 * @author: SongyangJi
 * @since: 2021-09-01 01:36:35
 * @description:
 */

@Slf4j
@RestController
@RequestMapping("station")
public class StationController {
    /**
     * 服务对象
     */
    @Resource
    private StationService stationService;

    @GetMapping("/all")
    public ResponseEntity<List<Station>> listAllStations() {
        return ResponseEntity.ok(stationService.list());
    }

    @GetMapping("/{stationId}")
    public ResponseEntity<Station> getStationById(@PathVariable int stationId) {
        return ResponseEntity.ok(stationService.getById(stationId));
    }

    @GetMapping("/all-ordered")
    public ResponseEntity<List<StationsByFirstCharVO>> getStationsByFirstCharVO() {
        return ResponseEntity.ok(stationService.queryStationsByFirstCharVOs());
    }

}
